# Maintainer: Mazhar Hussain <realmazharhussain@gmail.com>

_realname=gst-plugins-rs
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgdesc='GStreamer plugins written in Rust (mingw-w64)' 
url="https://gitlab.freedesktop.org/gstreamer/$_realname"
pkgver=0.10.11
pkgrel=1
license=('spdx:LGPL-3.0-or-later'
         'spdx:Apache-2.0'
         'spdx:MIT'
         'spdx:MPL-2.0')
depends=(${MINGW_PACKAGE_PREFIX}-gtk4
         ${MINGW_PACKAGE_PREFIX}-libsodium
         ${MINGW_PACKAGE_PREFIX}-gstreamer
         ${MINGW_PACKAGE_PREFIX}-gst-plugins-base
         ${MINGW_PACKAGE_PREFIX}-gst-plugins-bad-libs
         ${MINGW_PACKAGE_PREFIX}-dav1d
         ${MINGW_PACKAGE_PREFIX}-libwebp)
makedepends=(${MINGW_PACKAGE_PREFIX}-pkgconf
             ${MINGW_PACKAGE_PREFIX}-rust
             ${MINGW_PACKAGE_PREFIX}-cargo-c)
source=("$url/-/archive/$pkgver/$_realname-$pkgver.tar.bz2")
sha256sums=('150d5d5dbb78d8a0f46aa9f4fb25edbbc54a9599d583bf40d1f3f46fe1f13a51')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
arch=(any)

prepare() {
  cd $_realname-$pkgver
  cargo fetch
}

_cargo_opts=(--workspace
             --offline
             --release
             --library-type=cdylib
             --prefix="${MINGW_PREFIX}"
             --exclude gst-plugin-csound
             --exclude gst-plugin-aws)

build() {
  cd $_realname-$pkgver
  MSYS2_ARG_CONV_EXCL="--prefix=" cargo cbuild "${_cargo_opts[@]}"
}

check() {
  cd $_realname-$pkgver
  MSYS2_ARG_CONV_EXCL="--prefix=" cargo ctest "${_cargo_opts[@]}" --target-dir=tests-build
}

package() {
  cd $_realname-$pkgver
  MSYS2_ARG_CONV_EXCL="--prefix=" cargo cinstall "${_cargo_opts[@]}" --destdir="$pkgdir"
  rm "$pkgdir/$MINGW_PREFIX"/lib/gstreamer-1.0/*.def
  install -Dm644 -t "$pkgdir/$MINGW_PREFIX"/share/licenses/$_realname/ LICENSE*
}
